package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.domain.Student;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.StudentService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public PageInfo<Student> findAll(Integer currentPage,Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Student> all = studentMapper.findAll();
        PageInfo<Student> pageInfo = new PageInfo<>(all);
        return pageInfo;
    }

    @Override
    public void save(Student student) {
        studentMapper.save(student);
    }

    @Override
    public void delete(String number) {
        studentMapper.delete(number);
    }

    @Override
    public void update(Student student) {
        studentMapper.update(student);
    }
}
